<%@ page pageEncoding="utf-8" %>
<%@include file="/commons/taglibs.jsp" %>
<!DOCTYPE html>
<html>
<fmt:bundle basename="res">
<head>
    <meta charset="utf-8">
    <title><fmt:message key='fxsz'/></title>
    <jsp:include page="/WEB-INF/commons/commons-header.jsp" flush="true"/>
    <style>
        html {
            background: #fff;
        }

        .layui-form-label {
            width: 150px;
        }

        .layui-input-block {
            margin-left: 180px;
        }
    </style>
</head>

<body>

<div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
    <ul class="layui-tab-title">
        <li class="layui-this"><fmt:message key='fxsz'/></li>
        <li><a href="${web_domain}/distribution/setting/modify?flag=2"><fmt:message key='jssz'/></a></li>
    </ul>
    <div class="layui-tab-content" style="height: 100%;">
        <div class="layui-tab-item layui-show">
            <div class="layui-container">
                <div class="layui-form" lay-filter="layuiadmin-app-form-list" id="layuiadmin-app-form-list" style="padding: 20px 30px 0 0;">
                    <form:form commandName="setting" method="post" action="${web_domain}/distribution/setting/modify">

                        <input type="hidden" name="_method" value="PUT">
                        <input type="hidden" name="flag" value="${flag}">
                        <form:hidden path="id"/>

                        <div class="layui-form-item">
                            <label class="layui-form-label"><fmt:message key='kqfx'/></label>
                            <div class="layui-input-block">
                                <input type="radio" title="<fmt:message key='kq'/>" name="enable" value="1" <c:if test="${setting.enable}">checked</c:if>>
                                <input type="radio" title="<fmt:message key='jy'/>" name="enable" value="0" <c:if test="${!setting.enable}">checked</c:if>>
                            </div>
                        </div>

                        <div class="layui-form-item">
                            <label class="layui-form-label"><fmt:message key='fxssh'/></label>
                            <div class="layui-input-block">
                                <input type="radio" title="<fmt:message key='kq'/>" name="distributorCheck" value="1" <c:if test="${setting.distributorCheck}">checked</c:if>>
                                <input type="radio" title="<fmt:message key='jy'/>" name="distributorCheck" value="0" <c:if test="${!setting.distributorCheck}">checked</c:if>>
                            </div>
                        </div>

                        <div class="layui-form-item">
                            <label class="layui-form-label"><fmt:message key='fxszdkd'/></label>
                            <div class="layui-input-block">
                                <input type="radio" title="<fmt:message key='kq'/>" name="distributorAutoOpenShop" value="1" <c:if test="${setting.distributorAutoOpenShop}">checked</c:if>>
                                <input type="radio" title="<fmt:message key='jy'/>" name="distributorAutoOpenShop" value="0" <c:if test="${!setting.distributorAutoOpenShop}">checked</c:if>>
                            </div>
                        </div>

                        <div class="layui-form-item">
                            <label class="layui-form-label"><fmt:message key='fxsngms'/></label>
                            <div class="layui-input-block">
                                <input type="radio" title="<fmt:message key='zdms'/>" name="type" value="1" <c:if test="${setting.type eq 1}">checked</c:if>>
                                <input type="radio" title="<fmt:message key='ngms'/>" name="type" value="2" <c:if test="${setting.type eq 2}">checked</c:if>>
                                <input type="radio" title="<fmt:message key='jyngms'/>" name="type" value="3" <c:if test="${setting.type eq 3}">checked</c:if>>
                            </div>
                        </div>

                        <div class="layui-form-item">
                            <label class="layui-form-label"><fmt:message key='hygxbdyxq'/></label>
                            <div class="layui-input-block">
                                <input type="radio" title="<fmt:message key='yjbd'/>" lay-filter="memberBindValid" name="memberBindValid" value="-1" <c:if test="${setting.memberBindValid eq -1}">checked</c:if>>
                                <input type="radio" id="memberBindValidValueRadio" title="<fmt:message key='xsbd'/>" lay-filter="memberBindValid" name="memberBindValid" value="${setting.memberBindValid > -1 ? setting.memberBindValid : 0}" <c:if test="${setting.memberBindValid > -1}">checked</c:if>>
                            </div>
                        </div>

                        <div id="memberBindValid" class="layui-form-item <c:if test="${setting.memberBindValid == null || setting.memberBindValid eq -1}">layui-hide</c:if>">
                            <label class="layui-form-label"><fmt:message key='bdts'/></label>
                            <div class="layui-inline">
                                <div class="layui-input-inline">
                                    <input type="text" class="layui-input" id="memberBindValidValue" <c:if test="${setting.memberBindValid > 0}">value="${setting.memberBindValid}"</c:if>>
                                </div>
                                <div class="layui-form-mid"><fmt:message key='t'/></div>
                            </div>
                        </div>

                        <div class="layui-form-item">
                            <label class="layui-form-label"><fmt:message key='yjgs'/></label>
                            <div class="layui-input-block">
                                <input type="radio" title="<fmt:message key='gxlyx'/>" name="performanceAttribution" value="1" <c:if test="${setting.performanceAttribution eq 1}">checked</c:if>>
                                <input type="radio" title="<fmt:message key='fxryx'/>" name="performanceAttribution" value="2" <c:if test="${setting.performanceAttribution eq 2}">checked</c:if>>
                            </div>
                        </div>

                        <div class="layui-form-item">
                            <label class="layui-form-label"></label>
                            <div class="layui-input-inline">
                                <input type="button" value="<fmt:message key='qd1'/>" id="submit" class="layui-btn">
                            </div>
                        </div>

                    </form:form>
                </div>
            </div>
        </div>
    </div>
</div>

<script>

    layui.use(['form', 'layer'], function () {

        var layer = layui.layer;
        var form = layui.form;

        var ratioValue = '${setting.memberBindValid}' || 0;

        form.on('radio(memberBindValid)', function (e) {
            ratioValue = e.value;
            if (e.value > -1) {
                $("#memberBindValid").removeClass("layui-hide");
            } else {
                $("#memberBindValid").addClass("layui-hide");
            }
        });

        $("#submit").click(function () {

            if (ratioValue > -1) {
                $("#memberBindValidValueRadio").val($("#memberBindValidValue").val());
            }

            $("#setting").ajaxSubmit({
                success: function (res) {
                    if (res.status) {
                        layer.msg("<fmt:message key='bccg'/>");
                    } else {
                        layer.alert(res.message);
                    }
                }
            });

        });

    });

</script>
</body>
</fmt:bundle>
</html>